package com.chixing.controller;


import com.chixing.pojo.OrderInfo;
import com.chixing.service.OrderInfoService;
import com.chixing.util.ServerResponse;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class OrderInfoController {
    @Autowired
    private OrderInfoService orderInfoService;
    @RequestMapping("orderInfo/pageNum")
    @ResponseBody
    public PageInfo<OrderInfo> getAllOrder(Integer pagenum){
        System.out.println(pagenum);
        if(pagenum ==null){
            pagenum=1;
        }
        PageInfo<OrderInfo> pageInfo =orderInfoService.getByPage(pagenum);
             return  pageInfo;
    }
    @RequestMapping("orderInfo/{id}")
    @ResponseBody
    public ServerResponse getById(@PathVariable("id") Integer id){
        return  orderInfoService.getById(id);
    }


    @RequestMapping("customer/orderInfo")
    @ResponseBody
    public ServerResponse getAll(){
        return orderInfoService.getAll();
    }

    @RequestMapping("customer/orderAll")
    @ResponseBody
    public ServerResponse getOrderAll(){
        return orderInfoService.selectByOrderInfoId();
    }

}
